﻿Imports System.Data.SqlClient
Public Class clsPresupuesto
    Private mintIdPresupuesto As Integer
    Private mstrEmpresa As String
    Private mstrTipo As String
    Private mintAnio As Integer
    Private mdblEnero As Double
    Private mdblFebrero As Double
    Private mdblMarzo As Double
    Private mdblAbril As Double
    Private mdblMayo As Double
    Private mdblJunio As Double
    Private mdblJulio As Double
    Private mdblAgosto As Double
    Private mdblSeptiembre As Double
    Private mdblOctubre As Double
    Private mdblNoviembre As Double
    Private mdblDiciembre As Double
    Public Property IdPresupuesto() As Integer
        Get
            Return mintIdPresupuesto
        End Get
        Set(ByVal value As Integer)
            mintIdPresupuesto = value
        End Set
    End Property
    Public Property Empresa() As String
        Get
            Return mstrEmpresa
        End Get
        Set(ByVal value As String)
            mstrEmpresa = value
        End Set
    End Property
    Public Property Tipo() As String
        Get
            Return mstrTipo
        End Get
        Set(ByVal value As String)
            mstrTipo = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Enero() As Double
        Get
            Return mdblEnero
        End Get
        Set(ByVal value As Double)
            mdblEnero = value
        End Set
    End Property
    Public Property Febrero() As Double
        Get
            Return mdblFebrero
        End Get
        Set(ByVal value As Double)
            mdblFebrero = value
        End Set
    End Property
    Public Property Marzo() As Double
        Get
            Return mdblMarzo
        End Get
        Set(ByVal value As Double)
            mdblMarzo = value
        End Set
    End Property
    Public Property Abril() As Double
        Get
            Return mdblAbril
        End Get
        Set(ByVal value As Double)
            mdblAbril = value
        End Set
    End Property
    Public Property Mayo() As Double
        Get
            Return mdblMayo
        End Get
        Set(ByVal value As Double)
            mdblMayo = value
        End Set
    End Property
    Public Property Junio() As Double
        Get
            Return mdblJunio
        End Get
        Set(ByVal value As Double)
            mdblJunio = value
        End Set
    End Property
    Public Property Julio() As Double
        Get
            Return mdblJulio
        End Get
        Set(ByVal value As Double)
            mdblJulio = value
        End Set
    End Property
    Public Property Agosto() As Double
        Get
            Return mdblAgosto
        End Get
        Set(ByVal value As Double)
            mdblAgosto = value
        End Set
    End Property
    Public Property Septiembre() As Double
        Get
            Return mdblSeptiembre
        End Get
        Set(ByVal value As Double)
            mdblSeptiembre = value
        End Set
    End Property
    Public Property Octubre() As Double
        Get
            Return mdblOctubre
        End Get
        Set(ByVal value As Double)
            mdblOctubre = value
        End Set
    End Property
    Public Property Noviembre() As Double
        Get
            Return mdblNoviembre
        End Get
        Set(ByVal value As Double)
            mdblNoviembre = value
        End Set
    End Property
    Public Property Diciembre() As Double
        Get
            Return mdblDiciembre
        End Get
        Set(ByVal value As Double)
            mdblDiciembre = value
        End Set
    End Property

    Public Sub New()
        mintIdPresupuesto = 0
        mstrEmpresa = ""
        mstrTipo = ""
        mintAnio = 0
        mdblEnero = 0
        mdblFebrero = 0
        mdblMarzo = 0
        mdblAbril = 0
        mdblMayo = 0
        mdblJunio = 0
        mdblJulio = 0
        mdblAgosto = 0
        mdblSeptiembre = 0
        mdblOctubre = 0
        mdblNoviembre = 0
        mdblDiciembre = 0
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Presupuesto (" & _
                            "Empresa," & _
                            "Tipo," & _
                            "Anio," & _
                            "Enero," & _
                            "Febrero," & _
                            "Marzo," & _
                            "Abril," & _
                            "Mayo," & _
                            "Junio," & _
                            "Julio," & _
                            "Agosto," & _
                            "Septiembre," & _
                            "Octubre," & _
                            "Noviembre," & _
                            "Diciembre)" & _
                            "VALUES (" & _
                            "@Empresa," & _
                            "@Tipo," & _
                            "@Anio," & _
                            "@Enero," & _
                            "@Febrero," & _
                            "@Marzo," & _
                            "@Abril," & _
                            "@Mayo," & _
                            "@Junio," & _
                            "@Julio," & _
                            "@Agosto," & _
                            "@Septiembre," & _
                            "@Octubre," & _
                            "@Noviembre," & _
                            "@Diciembre) "


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("Empresa", mstrEmpresa)
        Command.Parameters.AddWithValue("Tipo", mstrTipo)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Enero", mdblEnero)
        Command.Parameters.AddWithValue("Febrero", mdblFebrero)
        Command.Parameters.AddWithValue("Marzo", mdblMarzo)
        Command.Parameters.AddWithValue("Abril", mdblAbril)
        Command.Parameters.AddWithValue("Mayo", mdblMayo)
        Command.Parameters.AddWithValue("Junio", mdblJunio)
        Command.Parameters.AddWithValue("Julio", mdblJulio)
        Command.Parameters.AddWithValue("Agosto", mdblAgosto)
        Command.Parameters.AddWithValue("Septiembre", mdblSeptiembre)
        Command.Parameters.AddWithValue("Octubre", mdblOctubre)
        Command.Parameters.AddWithValue("Noviembre", mdblNoviembre)
        Command.Parameters.AddWithValue("Diciembre", mdblDiciembre)
       

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el presupuesto ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
